package com.kim.rssreader.utils;

import java.io.File;

import android.os.Environment;
import android.os.StatFs;

public class SDCardUtils {

	/**
	 * SDCard根路径
	 */
	public static final File fileDir = Environment
			.getExternalStorageDirectory();

	/**
	 * SDCard目录信息对象
	 */
	public static final StatFs statFs = new StatFs(fileDir.getPath());

	private static final int SDCARD_LIMITED_SIZE = 1024 * 1024 * 8; // SDCard至少保证8M空间

	public static final boolean sdcardAvailable() {
		return (Environment.MEDIA_MOUNTED.equals(Environment
				.getExternalStorageState()));
	}

	public static final boolean sdcardCanWrite() {

		if (!sdcardAvailable()) { // SDCard未挂载
			return false;
		}
		return statFs.getAvailableBlocks() > SDCARD_LIMITED_SIZE;
	}

}
